﻿package mortal.game.view.copy.worldBoss
{
    import Message.Client.*;
    import Message.Game.*;
    import Message.Public.*;
    import fl.data.*;
    import flash.utils.*;
    import mortal.game.view.copy.worldBoss.WorldBossAllot.*;

    public class WorldBossCache extends Object
    {
        private var _belongGuildId:SEntityId;
        private var _sWorldBossHurtList:SWorldBossHurtList;
        private var _holeReward:DataProvider;
        public var isInPreTime:Boolean = false;
        public var bossStat:Dictionary;
        public var maxLevel:int;
        private var _dicBossCodeItem:Dictionary;
        private var _dicBossCodeBetArray:Dictionary;

        public function WorldBossCache()
        {
            this._dicBossCodeItem = new Dictionary();
            this._dicBossCodeBetArray = new Dictionary();
            return;
        }// end function

        public function get belongGuildId() : SEntityId
        {
            return this._belongGuildId;
        }// end function

        public function set belongGuildId(param1:SEntityId) : void
        {
            this._belongGuildId = param1;
            return;
        }// end function

        public function get worldBossHurtList() : SWorldBossHurtList
        {
            return this._sWorldBossHurtList;
        }// end function

        public function set worldBossHurtList(param1:SWorldBossHurtList) : void
        {
            this._sWorldBossHurtList = param1;
            return;
        }// end function

        public function getBossIsDeath(param1:int) : Boolean
        {
            return !(this.bossStat && this.bossStat[param1]);
        }// end function

        public function updateBetInfo(param1:SGuildItemBetUpdateInfo) : void
        {
            var _loc_4:* = undefined;
            var _loc_5:WorldBossAllotCellData = null;
            var _loc_2:* = this._dicBossCodeItem[param1.bossCode];
            if (_loc_2 && _loc_2.status != EWorldBossAllotStatus._ESignUp && param1.status == EWorldBossAllotStatus._ESignUp)
            {
                this.clearWorldBoss(_loc_2.bossCode);
            }
            this._dicBossCodeItem[param1.bossCode] = param1;
            var _loc_3:* = this._dicBossCodeBetArray[param1.bossCode];
            if (!_loc_3)
            {
                _loc_3 = new Dictionary();
                this._dicBossCodeBetArray[param1.bossCode] = _loc_3;
            }
            for (_loc_4 in param1.applyInfo)
            {
                
                if (!_loc_3[_loc_4])
                {
                    _loc_3[_loc_4] = new WorldBossAllotCellData();
                }
                _loc_5 = _loc_3[_loc_4];
                _loc_5.copyFromInfo(param1, _loc_4);
            }
            return;
        }// end function

        public function getBetInfo(param1:int) : SGuildItemBetUpdateInfo
        {
            return this._dicBossCodeItem[param1];
        }// end function

        public function getAllotMsg(param1:int) : Array
        {
            var _loc_4:* = undefined;
            if (!this._dicBossCodeBetArray || !this._dicBossCodeBetArray[param1])
            {
                return [];
            }
            var _loc_2:Array = [];
            var _loc_3:* = this._dicBossCodeBetArray[param1];
            for (_loc_4 in _loc_3)
            {
                
                _loc_2.push(_loc_3[_loc_4]);
            }
            return _loc_2;
        }// end function

        public function getAllotSelfMsg(param1:int) : WorldBossAllotCellData
        {
            var _loc_3:int = 0;
            var _loc_4:WorldBossAllotCellData = null;
            var _loc_2:* = this.getAllotMsg(param1);
            if (_loc_2 && _loc_2.length)
            {
                _loc_3 = 0;
                while (_loc_3 < _loc_2.length)
                {
                    
                    _loc_4 = _loc_2[_loc_3] as WorldBossAllotCellData;
                    if (_loc_4.isSelf)
                    {
                        return _loc_4;
                    }
                    _loc_3++;
                }
            }
            return null;
        }// end function

        public function getAllotMsgByItemCode(param1:int, param2:int) : WorldBossAllotCellData
        {
            if (!this._dicBossCodeBetArray || !this._dicBossCodeBetArray[param1])
            {
                return null;
            }
            return this._dicBossCodeBetArray[param1][param2];
        }// end function

        public function updateDiceInfo(param1:SGuildItemDiceUpdateInfo) : void
        {
            if (!this._dicBossCodeBetArray || !this._dicBossCodeBetArray[param1.bossCode])
            {
                return;
            }
            var _loc_2:* = this._dicBossCodeBetArray[param1.bossCode][param1.itemCode];
            _loc_2.addPlayerDiceMsg(param1);
            return;
        }// end function

        public function clearWorldBoss(param1:int) : void
        {
            delete this._dicBossCodeItem[param1];
            delete this._dicBossCodeBetArray[param1];
            return;
        }// end function

    }
}
